<%@ page language="java" import="java.util.*,com.xq.shop.po.Role" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<jsp:include page="/jsp/admin/common.jsp" />
<jsp:include page="/jsp/formHead.jsp" />
<script type="text/javascript">
$().ready(function(){

	var default_PID = "${privilege.menu_id}" || "";

	$("select[name='menu_id']").val(default_PID);
		
	$("#backButton").click(function(){
		location.href = basePath + "jsp/admin/setting/privilege_list.jsp";
	});
	
	$("#form_edit").validate({	//验证配置
		rules : {
			menu_id : "required",
			uri : "required"
		},
		messages : {
			menu_id : {required : "必选"}
		}
	});

	$("#backButton").click(function(){
		location.href = basePath + "jsp/admin/setting/privilege_list.jsp";
	});

	//判断是否是编辑状态
	var in_edit = ${!empty privilege.id};
	
	if(in_edit){
		$("div.path").append("<span>权限修改</span>");
	} else {
		$("div.path").append("<span>权限创建</span>");
	}
});
</script>
</head>
<body>
	<div class="path">
		<a href="">首页</a> &raquo;
	</div>
	<form id="form_edit" method="post" action="<%=basePath %>admin/privilege_save.do">
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField">*</span>名称:
				</th>
				<td>
					<input type="hidden" name="id" value="${privilege.id }"/>
					<select name="menu_id">
						<c:forEach var="menu" items="${menuList }">
							<option value="${menu.id }" >${menu.name }</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>URI:
				</th>
				<td>
					<input type="text" name="uri" class="text" maxlength="200" value="${privilege.uri }"/>
				</td>
			</tr>
			<tr>
				<th>
					备注:
				</th>
				<td>
					<input type="text" name="remark" class="text" maxlength="500" value="${privilege.remark }"/>
				</td>
			</tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="确定" />
					<input type="button" id="backButton" class="button" value="返回"/>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>